import http from "@/api";
import { ResPage } from "@/api/interface/index";
import { Variable } from "@/api/interface/iot";
// import { Device, Variable } from "@/api/interface/iot";
// import { getDeviceListAll } from "./device";

export const getPageList = async (params: Variable.ReqVariable, loading?: boolean) => {
	// let res = await getDeviceListAll({ pageIndex: 1, pageSize: 9999 });
	// params.sns = res.result?.records?.map((record: Device.ResDeviceInfo) => record.sn).join(",");
	return http.get<ResPage<Variable.ResVariable[]>>(`/var/sensor/find`, params, {
		headers: { noLoading: loading }
	});
};
export const getProductPageList = async (params: Variable.ReqVariable) => {
	return http.get<ResPage<Variable.ResVariable[]>>(`/product/variable/find`, params);
};
export const addProductInfo = (params: Variable.ResVariable) => {
	return http.post(`/product/variable/add`, params);
};
export const getInfo = (params: Variable.ReqVariable) => {
	return http.get<Variable.ResVariable>(`/variable/get`, params);
};
export const addInfo = (params: Variable.ResVariable) => {
	return http.post(`/var/sensor/add`, params);
};
export const modInfo = (params: Variable.ResVariable) => {
	return http.post(`/var/sensor/modify`, params);
};
export const delInfo = (params: any) => {
	return http.post(`/var/sensor/remove`, params);
};
export const exportVariableExcel = (params: { [key: string]: any }) => {
	return http.downloadGet("/var/sensor/export", params, { responseType: "blob" });
};
export const importVariableExcel = (params: FormData) => {
	return http.post(`/var/sensor/import`, params);
};
export const saveDeviceConfig = (params: any) => {
	return http.post(`/device/config/save`, params);
};
export const saveSoftGatewayConfig = (params: any) => {
	return http.post(`/soft-gateway/config/save`, params);
};
export const saveGatewayConfig = (params: any) => {
	return http.post(`/gateway/config/save`, params);
};
export const saveProductConfig = (params: any) => {
	return http.post(`/product/config/save`, params);
};
//查询设备历史数据报表
export const devHistorydataReport = (params: any) => {
	return http.post<any>(`/device/historydata/report`, params);
};
//报表表单收藏列表
export const reportFind = () => {
	return http.get(`/device/report/form/find`);
};
//报表表单收藏添加
export const reportAdd = (params: any) => {
	return http.post(`/device/report/form/add`, params);
};
//报表表单收藏删除
export const reportDel = (params: any) => {
	return http.post(`/device/report/form/del`, params);
};
//编辑控制模型
export const funcMod = (params: any) => {
	return http.post(`/profile/func/modify`, params);
};
